<?php

class ApiController extends BaseController {
        
    public function indexAction($request) {
		echo "Ouch!";
    	exit;
    }
    
    public function listAction($request) {
    	$p100 = p1_event::getAll();
    	echo base64_encode(serialize($p100));
    	
    	exit;
    }
    
    public function getIdAction($request) {
    	$arg0 = isset($request['arg0']) ? $request['arg0'] : "";
    	$event = p1_event::get(addslashes(seourl($arg0)));
    	if($event->id > 0) {
    		die($this->getEvent($event));
    	}
    	echo "Ouch!";
    	exit;
    }
    
    public function getAction($request) {
    	$arg0 = isset($request['arg0']) ? $request['arg0'] : "";
    	$event = p1_event::get(addslashes(seourl($arg0)), "name");
    	if($event->id > 0) {
    		die($this->getEvent($event));
    	}
    	echo "Ouch!";
    	exit;
    }
    
    private function getEvent($event) {
    	if(!preg_match('/http:/', $event->picture)) {
    		$event->picture = 'http://www.100.peak.com/uploads/' . $event->picture;
    	}
    	$event->details = p1_event_detail::get($event->id, "event");
    	echo base64_encode(serialize($event));
    	
    	return;
    }

}

?>